package com.example.warehousems.event.listener;

import com.example.warehousems.component.UserInfo;
import com.example.warehousems.event.event.InOutEvent;
import com.example.warehousems.event.event.UserRequestEvent;
import com.example.warehousems.service.ActivityService;
import com.example.warehousems.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

import javax.accessibility.AccessibleValue;

@Component
public class ActivityEventListener implements ApplicationListener<UserRequestEvent> {
    @Autowired
    private ActivityService activityService;
    @Override
    public void onApplicationEvent(UserRequestEvent event) {
        var userId = Integer.valueOf(UserInfo.get("id"));
        activityService.addActivity(userId, event.getTitle(), event.getDescription());
        System.out.println(event);
    }
}
